package com.bcbim.api_web.sys.init.code;

import com.bcbim.common.sys.Constant;
import com.google.common.collect.Maps;

import java.lang.reflect.Field;
import java.util.Map;

/**
 * @Description: 系统内码值映射
 * @Author haoshuai
 * @Date 2020/8/26
 * @Version V1.0
 **/
public class CodeMap {

    //存放 码值类型 与 对应静态常量属性名 映射关系集合
    public static Map<String, String> CODE_MAPPING = Maps.newHashMap();

    static {
        Field[] fields = CodeMap.class.getDeclaredFields();
        //遍历类属性, 获取码值类型 与 对应静态常量属性名 放入映射集合
        for (Field field : fields) {
            if (field.getType().toString().equals(Constant.CLASS_STRING)) {
                //获取属性权限
                boolean accessFlag = field.isAccessible();
                //打开访问权限
                field.setAccessible(true);
                //码值类型 与 对应静态常量属性名 放入映射集合
                try {
                    CODE_MAPPING.put((String) field.get(null), field.getName());
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
                //恢复访问权限
                field.setAccessible(accessFlag);
            }
        }
    }

    //文件状态
    private static final String FILE_STATUS_TYPE = "fileStatusType";
    public static Map<String, String> FILE_STATUS_MAP = Maps.newHashMap();
    /**
     * 顶级类别
     */
    private static final String TOP_CATEGORY_TYPE = "topCategoryType";
    public static Map<String, String> TOP_CATEGORY_MAP = Maps.newHashMap();
    /**
     * 分摊方式
     */
    private static final String ALLOCATION_METHOD_TYPE = "allocationMethodType";
    public static Map<String, String> ALLOCATION_METHOD_MAP = Maps.newHashMap();
    /**
     * 标签显示
     */
    private static final String LABEL_TYPE = "labelType";
    public static Map<String, String> LABEL_MAP = Maps.newHashMap();
    /**
     * 分组
     */
    private static final String GROUP_TYPE = "groupType";
    public static Map<String, String> GROUP_MAP = Maps.newHashMap();
    /**
     * x轴显示
     */
    private static final String X_AXIS_TYPE = "xAxisType";
    public static Map<String, String> X_AXIS_MAP = Maps.newHashMap();
    /**
     * y轴显示
     */
    private static final String Y_AXIS_TYPE = "yAxisType";
    public static Map<String, String> Y_AXIS_MAP = Maps.newHashMap();
    // 流向
    private static final String FLOW_DIRECTION_TYPE = "flowDirectionType";
    public static Map<String, String> FLOW_DIRECTION_MAP = Maps.newHashMap();

    // 用途
    private static final String USES_TYPE = "usesType";
    public static Map<String, String> USES_MAP = Maps.newHashMap();

    // 材质
    private static final String MATERIAL_TYPE = "materialType";
    public static Map<String, String> MATERIAL_MAP = Maps.newHashMap();

    // 埋设方式
    private static final String BURY_TYPE = "buryType";
    public static Map<String, String> BURY_MAP = Maps.newHashMap();

    // 特征
    private static final String FEATURE_TYPE = "featureType";
    public static Map<String, String> FEATURE_MAP = Maps.newHashMap();

    // 附属物
    private static final String ATTACHMENT_TYPE = "attachmentType";
    public static Map<String, String> ATTACHMENT_MAP = Maps.newHashMap();

    // 精度级别
    private static final String ACCURACY_LEVEL_TYPE = "accuracyLevelType";
    public static Map<String, String> ACCURACY_LEVEL_MAP = Maps.newHashMap();

    // 养护类别
    private static final String MAINTENANCE_CATEGORY_TYPE = "maintenanceCategoryType";
    public static Map<String, String> MAINTENANCE_CATEGORY_MAP = Maps.newHashMap();

    // 健康监测状态
    private static final String HEALTH_STATE_TYPE = "healthStateType";
    public static Map<String, String> HEALTH_STATE_MAP = Maps.newHashMap();

    // 缺陷类型
    private static final String DEFECT_TYPE = "defectType";
    public static Map<String, String> DEFECT_MAP = Maps.newHashMap();

    // 传感器类型
    private static final String SENSOR_TYPE = "sensorType";
    public static Map<String, String> SENSOR_MAP = Maps.newHashMap();

    //传感器报警类型
    private static final String SENSOR_ALARM_TYPE = "sensorAlarmType";
    public static Map<String, String> SENSOR_ALARM_MAP = Maps.newHashMap();

    //传感器数据报警类型
    private static final String SENSOR_DATA_ALARM_TYPE = "sensorDataAlarmType";
    public static Map<String, String> SENSOR_DATA_ALARM_MAP = Maps.newHashMap();
    //道路类型
    private static final String ROAD_TYPE = "roadType";
    public static Map<String, String> ROAD_MAP = Maps.newHashMap();
    //报警类型
    private static final String ASSET_ALARM_TYPE  = "assetAlarmType";
    public static Map<String, String> ASSET_ALARM_MAP = Maps.newHashMap();

    //阈值类型
    private static final String THRESHOLD_TYPE  = "thresholdType";
    public static Map<String, String> THRESHOLD_MAP = Maps.newHashMap();
    //1管井 2管线
    private static final String PIPELINE_TYPE  = "pipelineType";
    public static Map<String, String> PIPELINE_MAP = Maps.newHashMap();
    //问题状态
    private static final String PROBLEM_STATUS_TYPE = "problemStatusType";
    public static Map<String, String>  PROBLEM_STATUS_MAP = Maps.newHashMap();
}
